﻿using Wizard.Compiler.Parsers;

namespace Wizard.Compiler.Tokenizers
{
    internal class JavaTokenizer : BaseTokenizer
    {
        public JavaTokenizer(SourcePos sourcePos)
            : base(sourcePos)
        {
        }

        protected override TokenType ParseCurChar()
        {
            switch (mCurChar)
            {
                case '!':
                    return TokenType.operator_not;

                case '&':
                    NextChar();
                    if (mCurChar == '&')
                    {
                        NextChar();
                        return TokenType.operator_binary_and;
                    }
                    else
                    {
                        return TokenType.operator_and;
                    }

                case '|':
                    NextChar();
                    if (mCurChar == '|')
                    {
                        NextChar();
                        return TokenType.operator_binary_or;
                    }
                    else
                    {
                        return TokenType.operator_or;
                    }

                case '/':
                    NextChar();
                    if ((mCurChar == '/'))
                    {
                        NextChar();
                        skipEndOfLineComment();
                        return TokenType.none; // comment
                    }
                    else
                    {
                        return TokenType.operator_div;
                    }

                default:
                    return base.ParseCurChar();
            }
        }

        protected internal override int GetUnaryPriority(TokenType type)
        {
            throw new System.NotImplementedException();
        }

        protected internal override int GetPriority(Wizard.Runtime.IHasValue ValueLeft, TokenType tt)
        {
            throw new System.NotImplementedException();
        }
    }
}